package phase01.module3.code.question1;

/**
 * 编程统计字符串"ABCD123!@#$%ab"中大写字母、小写字母、数字、其它字符的个数并打 印出来。
 */

public class CharCount {
    public static void main(String[] args) {
        String s = "ABCD123!@#$%ab";
        int upperCharCount = 0;
        int lowerCharCount = 0;
        int numberCharCount = 0;
        int otherCharCount = 0;
        for(int i = 0;i < s.length(); i++) {
            char c = s.charAt(i);
            if(c >= 97 && c <= 122) {
                lowerCharCount += 1;
            }else if(c >= 65 && c <= 90) {
                upperCharCount += 1;
            }else if(c >= 48 && c <= 57) {
                numberCharCount += 1;
            } else {
                otherCharCount += 1;
            }
        }
        System.out.println("大写字母个数：" + upperCharCount);
        System.out.println("小写字母个数：" + lowerCharCount);
        System.out.println("数字个数：" + numberCharCount);
        System.out.println("其他字符个数：" + otherCharCount);
    }
}
